import java.util.ArrayList;
import java.util.Comparator;
@SuppressWarnings({"all"})
public class Main {
    public static void main(String[] args) {
        ArrayList<Employee> arrayList = new ArrayList<>();
        arrayList.add(new Employee("xx",2000,new Mydate(2021,2,23)));
        arrayList.add(new Employee("xxx",20000,new Mydate(2022,3,2)));
        arrayList.add(new Employee("xxx",20000,new Mydate(2020,6,22)));
        System.out.println(arrayList);
        arrayList.sort(new Comparator<Employee>() {
            @Override
            public int compare(Employee o1, Employee o2) {
                if (o1.getName().length() - o2.getName().length() != 0) {
                    return o1.getName().length() - o2.getName().length();
                }
                return o1.getBrithday().compareTo(o2.getBrithday());
            }
        });
        System.out.println(arrayList);
    }
}
class Mydate implements Comparable<Mydate>{
    private int year;
    private int month;
    private int day;

    public Mydate(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    @Override
    public String toString() {
        return "Mydate{" +
                "year='" + year + '\'' +
                ", month='" + month + '\'' +
                ", day='" + day + '\'' +
                '}';
    }


    @Override
    public int compareTo(Mydate o) {

        return 0;
    }
}
class Employee{
    private String name;
    public int sal;
    private Mydate brithday;

    public Employee(String name, int sal,Mydate mydate) {
        this.name = name;
        this.sal = sal;
       this.brithday=mydate;
    }

    public Mydate getBrithday() {
        return brithday;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSal() {
        return sal;
    }

    public void setSal(int sal) {
        this.sal = sal;
    }

    @Override
    public String toString() {
        return "\nEmployee{" +
                "name='" + name + '\'' +
                ", sal=" + sal +
                ", brithday=" + brithday +
                '}';
    }
}